	clear
	set more off
	set logtype text
	capture log close

use "EDCC_figures.dta", clear 
	
	
	gen temp=1

*figure 2
	preserve 
	replace psnp_hh2019_rv=0
	gen dropvar=1
	tempfile allhh
	save `allhh'
	restore 
	
	append using `allhh'
	
	gen food_insecure1=food_insecure*100
	graph bar food_insecure1 [aw=weight], over(year) over(psnp_hh2019_rv, gap(*1)) asyvars title("a) Food insecure households (%)", size(small)) ytitle("") legend(off) blabel(bar, format(%9.1f) size(vsmall)) bar(1,color()) bar(2,color()) bargap() saving("fig2_1", replace)	

	graph bar food_gap [aw=weight], over(year) over(psnp_hh2019_rv, gap(*1)) asyvars title("b) Food gap (number of months)", size(small)) ytitle("") legend(off) blabel(bar, format(%9.1f) size(vsmall))  bar(1,color()) bar(2,color()) bargap() saving("fig2_2", replace)
	
	graph bar food_gap [aw=weight], over(year) over(region) asyvars title("c) Food gap (number of months) by region", size(small)) ytitle("") blabel(bar, format(%9.1f) size(vsmall))  bar(1,color()) bar(2,color()) saving("fig2_3", replace)
	drop if dropvar==1
	drop psnp_hh2019_rv food_insecure1 dropvar 

	graph combine "fig2_1" "fig2_2" "fig2_3" , cols(1) rows(3)
	graph display, ysize(13) xsize(12)
	graph export "fig2.png", replace
	
	
	
*figure 3 	
	graph hbar (percent) temp [aw=weight] if year==2020, over(meb_q15) title("Compared to the same period last year, in the last 3 months" ///  
	"your problems of satisfying food needs of the household") title("")  ytitle("") blabel(bar, format(%9.1f) size(small)) saving("fig3_1", replace)
	
	graph hbar (percent) temp [aw=weight] if year==2020, over(meb_q15) over(high_covid2) title("")  ytitle("") blabel(bar, format(%9.1f) size(small)) saving("fig3_2", replace)	
	
	graph combine "fig3_1" "fig3_2", cols(1) rows(2)
	graph export "fig3.png", replace
	

*figure 4	
preserve 
	keep id FG*_mom weight year 
	rename FG*_mom FG*
	reshape long FG, i(id year) j(food_cat)
	label define fcat 1"All starchy staple foods" 2"Beans and peas" 3"Nuts and seeds" 4"Dairy" 5"Flesh foods" 6"Eggs" 7"Vitamin A-rich dark green leafy" 8"Other vitamin A-rich vegetables" 9"Other vegetables" 10"Other fruits", replace 
	label val food_cat fcat 
	collapse (mean) FG [aw=weight], by(year food_cat)
	replace FG=FG*100
	graph hbar (mean) FG, over(year) over(food_cat, sort(1)) blabel(bar) asyvars title("a) Diet diversity of mothers") ytitle("") blabel(bar, format(%9.1f) size(vsmall)) legend(off) saving("fig4_1", replace)	
restore 
	
preserve 
	keep id FG*_child weight year 
	rename FG*_child FG*
	reshape long FG, i(id year) j(food_cat)
	label define fcat 1"Grains, roots and tubers" 2"Legumes and nuts" 3"Dairy products" 4" Poultry, fish, meat" 5"Eggs" 6"Vitamin A rich fruits and vegetables" 7"Other fruits and vegetables", replace  
	label val food_cat fcat 
	replace FG=FG*100
	collapse (mean) FG [aw=weight], by(year food_cat)
	graph hbar (mean) FG, over(year) over(food_cat, sort(1)) blabel(bar) asyvars title("b) Diet diversity of children") ytitle("") blabel(bar, format(%9.1f) size(vsmall)) saving("fig4_2", replace)	
restore 	
	
	graph combine "fig4_1" "fig4_2", cols(1) rows(2) ysize(16) xsize(12)
	graph export "fig4.png", replace


*figure 5
	graph hbar (percent) temp [aw=weight] if year==2020, over(md_q15, sort(1)) blabel(bar) title("Which aspect of the coronavirus crisis has the greatest impact (%)") ytitle("") blabel(bar, format(%9.1f) size(small)) bar(2,color(red))  saving("fig5", replace)	
	graph export "fig5.png", replace


*figure 6
preserve 
	keep if year==2020 
	keep id mea_q11 mea_q12 mec_q17 mec_q19 mec_q20 mec_q16 mec_q18 mec_q21 mec_q22 mec_q23 weight temp
	rename mec_q17 cs1
	rename mec_q19 cs2
	rename mec_q20 cs3
	rename mec_q16 cs4
	rename mec_q18 cs5
	rename mec_q21 cs6
	rename mec_q22 cs7
	*rename mec_q23 cs8		
	recode mea_q11 (5=4)
	order id mea_q11 mea_q12 cs1 cs2 cs3 cs4 cs5 cs6 cs7 weight temp 
	reshape long cs, i(id) j(copst)
	label define cst 1"Reduced food consumption" 2"Reduced non-food consumption" 3"Reduced expenditure on agricultural inputs" 4"Used savings" 5"Borrowed money to buy food" 6"Sold consumer durables" 7"Sold productive assets" 8`""Sent household members" "to live elsewhere""'
	label val copst cst 
	label define q11 1"Much less" 2"Somewhat less" 3"Same" 4"More/much more"
	label val mea_q11 q11 

	recode mea_q11 (1 2=1) (3 4=2), gen (mea_q11_2) 
	label define q11_2 1"Less income" 2"Same or more income"
	label values mea_q11_2 q11_2  
	collapse (mean) cs [aw=weight], by(copst mea_q11_2 mea_q12) 
	replace cs=cs*100
	graph hbar (mean) cs if mea_q12==1, over(mea_q11_2) over(copst, sort(order) relabel(1"Reduced food consumption" 2"Reduced non-food consumption" 3`""Reduced expenditure on" "agricultural inputs""' 4"Used savings" 5"Borrowed money to buy food" 6"Sold consumer durables" 7"Sold productive assets" 8`""Sent household members" "to live elsewhere""') label(labsize(small))) title("Coping strategies by change in income (%)") ytitle("") asyvars blabel(bar, format(%9.1f) size(vsmall)) saving("fig6", replace)	
	graph export "fig6.png", replace
restore 
	
